package com.pan.order;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class OrderAnalysisReducer extends Reducer<Text, IntWritable,Text,IntWritable> {

    IntWritable outV = new IntWritable();

    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Reducer<Text, IntWritable, Text, IntWritable>.Context context) throws IOException, InterruptedException {
        int count = 0;
        while (values.iterator().hasNext()){
            IntWritable value =values.iterator().next();
            count += value.get();
        }
        outV.set(count);
        context.write(key,outV);
    }
}
